package com.hnu.web;

import com.hnu.model.User;

public class LoginAction extends BaseAction {
	private static final long serialVersionUID = -1077067630527308218L;
	private String userName;
	private String password;
	private String message = "";
	
	public String login()
	{
		User user = this.servLocator.getUserServ().verifyLogin(this.userName);
		if((user != null) && (user.getPassword().equals(this.password)))
		{
			this.session.put("user", user);
			return "success";
		}
		else
		{
			message = "用户名或者密码错误！ ";
			return "failure";
		}
	}
	
	public String logout()
	{
		this.session.clear();
		return "success";
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

}
